-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yarn workspace test fixture #681
base: master
Are you sure you want to change the base?
Conversation
If Jest is used in a monorepo and deps are hoisted, you need to pass custom diff --git a/fixtures/monorepo-yarn-workspace/packages/app0/__tests__/App.test.js b/fixtures/monorepo-yarn-workspace/packages/app0/__tests__/App.test.js
index 520b83c..5922637 100644
--- a/fixtures/monorepo-yarn-workspace/packages/app0/__tests__/App.test.js
+++ b/fixtures/monorepo-yarn-workspace/packages/app0/__tests__/App.test.js
@@ -1,6 +1,6 @@
import * as React from 'react';
import { mount } from 'enzyme';
-import App from '..';
+import App from '../App';
let subject;
afterEach(() => {
diff --git a/fixtures/monorepo-yarn-workspace/packages/app0/jest.config.js b/fixtures/monorepo-yarn-workspace/packages/app0/jest.config.js
index 5591324..2a0fa0a 100644
--- a/fixtures/monorepo-yarn-workspace/packages/app0/jest.config.js
+++ b/fixtures/monorepo-yarn-workspace/packages/app0/jest.config.js
@@ -11,4 +11,5 @@ module.exports = {
'.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|dds|ogg|json.resource)$':
require.resolve('react-native/jest/assetFileTransformer.js'),
},
+ rootDir: "../../"
};
diff --git a/fixtures/monorepo-yarn-workspace/packages/app0/package.json b/fixtures/monorepo-yarn-workspace/packages/app0/package.json
index 77c5c8f..62da0bf 100644
--- a/fixtures/monorepo-yarn-workspace/packages/app0/package.json
+++ b/fixtures/monorepo-yarn-workspace/packages/app0/package.json
@@ -16,7 +16,7 @@
},
"dependencies": {
"react": "16.8.3",
- "react-native": "0.59.10",
+ "react-native": "callstack/react-native#feat/apennine-0.59",
"react-native-gesture-handler": "^1.3.0",
"react-navigation": "^3.11.0",
"base-dll": "*"
diff --git a/fixtures/monorepo-yarn-workspace/packages/base-dll/package.json b/fixtures/monorepo-yarn-workspace/packages/base-dll/package.json
index 989d195..ae07b94 100644
--- a/fixtures/monorepo-yarn-workspace/packages/base-dll/package.json
+++ b/fixtures/monorepo-yarn-workspace/packages/base-dll/package.json
@@ -16,7 +16,7 @@
},
"dependencies": {
"react": "16.8.3",
- "react-native": "0.59.10",
+ "react-native": "callstack/react-native#feat/apennine-0.59",
"react-native-gesture-handler": "^1.3.0",
"react-navigation": "^3.11.0"
} After that I run into this: But IIRC this is expected, since we're running in a |
Talking with the affected team, they tried rootDir and ran into another problem when there is a platform override of a core component in the haste map, and that out-of-tree platform package is hoisted. I'm going to add another fixture to this PR based on the existing react-native-windows fixture to illustrate this part of the problem. I've added your diffs above in the meantime -- thanks! |
…sticexpialidocious yarn workspace fixture. This is a good text to have for regression, but also replicates the jest issue underlying the rootDir workaround.
@thymikee Thanks for looking into this! Setting
Have you seen this before? At first we thought it was still related to using a monorepo, but we were able to reproduce the same issue without a monorepo being part of the equation. Best I can tell, it happens when adding a component from |
Looking at the config: https://github.com/matthargett/haul/blob/197449d0a776bd26a64c3478feefe99454d42881/fixtures/react_native_windows_current_jest_haste/jest.config.js#L14-L19 seems like you tell Jest to only look for a single platform but in both |
@thymikee We tried swapping the entries, it had no effect on the output. If you need more to estimate the work to fix the jest problem, let us know. thanks for all your suggestions so far! |
Summary
This is a test fixture for 0.59 in a yarn workspace with proper hoisting. It reproduces an issue we have in jest, but I'd also like to see this real-world scenario covered in CI.
Test plan
Ran
yarn test
from the root. I get some failures that appear to be due to my Windows environment and are unrelated to the changes. I'd love help figuring that out, as the tests should be passing in